<%--
 *  File:   DefaultTaskSummary.jsp
 *  Author: David Zhang
 *  Date:   2002/02/18
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<%
  //Initial parameters.
  Category cat = Category.getInstance("jsp.DefaultTaskSummary");
  String strModuleName = "BIEE";
  String strTableName = "ovdefaulttask";
  String privilegeCode = "Z0704,L601";
  
%>



<%
  //Get userinfo from session.
  HashMap mapUserInfo = (HashMap) session.getAttribute("userinfo");
  String orgid = ((Integer) mapUserInfo.get("orgid")).toString();
%>

<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>


<html>

<head>
<title>DefaultTaskSummary</title>
<PageFlow:CheckPageFlow pageName="defaulttasksummary"/>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <link rel="stylesheet" href="../css/<%= strLanguageCode %>/main.css" type="text/css">
  <script language="JavaScript" src="../css/<%= strLanguageCode %>/script.js"></script>
  <script language="JavaScript" src="../js/FuncLib.js"></script>

<%@ include file="/inc/SummaryDivision.inc" %>

<%
  Vector defaultTaskSummary = (Vector) pageContext.getAttribute("defaulttasksummary");
  if ( defaultTaskSummary == null )  defaultTaskSummary = new Vector();

  String subjectcode = (String) pageContext.getAttribute("subjectcode");
  //String subjectcode = request.getParameter("subjectcode");

  if ( subjectcode == null )  subjectcode = "";
  //subjectcode = (String) session.getAttribute("subjectcode");

  if ( subjectcode == null )  subjectcode = "";

  Vector subjects = (Vector) pageContext.getAttribute("allsubject");
  if ( subjects == null )  subjects = new Vector();

  cat.debug("The defaultTaskSummary is:" + defaultTaskSummary);
  cat.debug("The strCurSearchName is :" + strCurSearchName);
  cat.debug("The strCurSearchValue is :" + strCurSearchValue);
  cat.debug("The strCurOrderByCol is :" + strCurOrderByCol);
  cat.debug("The strCurOrderByType is :" + strCurOrderByType);
  cat.debug("The nCurMaxItem is :" + nCurMaxItem);
  cat.debug("The nCurCount is :" + nCurCount);
  cat.debug("The nCurPageNo is :" + nCurPageNo);
  cat.debug("The nCurTotalPage is :" + nCurTotalPage);
  cat.debug("The nCurEndIndex is :" + nCurEndIndex);
  cat.debug("The bCurHasPre is :" + bCurHasPre);
  cat.debug("The bCurHasNext is :" + bCurHasNext);
%>

<script language="JavaScript">
parent.down.location.href = "Blank.jsp?<%= OvalTools.randomURL() %>";
<%--[SCRIPT]  var frm = document.defaulttasksummaryform;  [SCRIPT]--%>

function clickRadio(id)
{
  var frm = document.defaulttasksummaryform;
  frm.defaulttaskid.value = id;
  parent.down.location.href = "Blank.jsp?<%= OvalTools.randomURL() %>"
}

function page_delete()
{
  var frm = document.defaulttasksummaryform;
  var id = frm.defaulttaskid.value;
  if( id == null || id.length == 0 || id == "" || id == "-1" )  return;

  if ( ! confirm("<%= message.getMessage("ARE_YOU_SURE_DEL")%>") )  return;

  parent.down.location.href = "Blank.jsp?<%= OvalTools.randomURL() %>"
  frm.actionname.value = "delete";
  isRunning = true;
  frm.submit();
}

function page_new()
{
  var frm = document.defaulttasksummaryform;
  
  var value = frm.subjectcode.options[frm.subjectcode.selectedIndex].value;
  if ( value == "" )
  {
      alert("<%= message.getMessage("A_SubjectCode")%>");
      return;
  }
  parent.down.location.href = "DefaultTaskEdit.jsp?<%= OvalTools.randomURL() %>&subjectcode=" + value;
}

function page_edit()
{
  var frm = document.defaulttasksummaryform;
  var value = frm.subjectcode.options[frm.subjectcode.selectedIndex].value;
  var id = frm.defaulttaskid.value;
  if( id == null || id.length == 0 || id == "" || id == "-1" )  return;
  <%--[SCRIPT]  alert("id=" + id + "/subjectcode=" + frm.subjectcode.value);  [SCRIPT]--%>
  parent.down.location.href = "DefaultTaskEdit.jsp?<%= OvalTools.randomURL() %>&defaulttaskid=" + id +
                              "&subjectcode=" + value +
                              "&languagecode=<%= strLanguageCode %>";
}

function page_summary(actionvalue, orderbyname)
{
  <%--[SCRIPT]  alert("actionvalue=" + actionvalue + "/orderbyname=" + orderbyname);  [SCRIPT]--%>
  var frm = document.defaulttasksummaryform;
  var editform = summaryPrepare(frm, actionvalue, orderbyname);
  editform.action = "DefaultTaskSummary.jsp?<%= OvalTools.randomURL() %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();
}

function page_condition()
{
  var frm = document.defaulttasksummaryform;
  parent.down.location.href = "DefaultTaskCondition.jsp?<%= OvalTools.randomURL() %>&defaulttaskid=" +
                              frm.defaulttaskid.value +
                              "&languagecode=<%= strLanguageCode %>"+
                              "&subjectcode=<%=JspHelper.filterNull( subjectcode )%>";
}

function radioSelect(name)
{
        var frm = document.defaulttasksummaryform;
        var obj = eval("document.defaulttasksummaryform." + name);
        obj.checked = true;
        frm.defaulttaskid.value = obj.value;
}
function page_advanced()
{
   var frm = document.defaulttasksummaryform;
  parent.down.location.href = "DefaultTaskAdvancedCondition.jsp?<%= OvalTools.randomURL() %>&defaulttaskid=" +
                              frm.defaulttaskid.value +
                              "&languagecode=<%= strLanguageCode %>"+
                              "&subjectcode=<%=JspHelper.filterNull( subjectcode )%>";

}
</script>
</head>

<body>
  <form name="defaulttasksummaryform" method="post" action="../Dispatcher"  target="_parent">
  <input type="hidden" name="pagename" value="defaulttasksummary">
  <input type="hidden" name="actionname">
  <input type="hidden" name="languagecode" value="<%= strLanguageCode %>">
  <input type="hidden" name="orgid" value="<%=JspHelper.filterNull( orgid )%>">

  <input type="hidden" name="searchnamealias" value="">
  <input type="hidden" name="searchvaluealias" value="">
  <input type="hidden" name="searchvalue" value="">
  <input type="hidden" name="searchname" value="">

<%-- page location --%>
<%@ include file="/inc/PageLocation.inc" %>

<table width="100%" cellspacing="0" border="0" cellpadding="0">
<tr>
  <td>
    <table width="100%" cellspacing="0" cellpadding="0" border="0">
      <tr><td class="summary_top" colspan="2" ></td></tr>
      <tr>
        <td width="350"><%= label.getLabelName("L_SubjectType") + label.getLabelName("L_Colon") %>
          <select name="subjectcode" onChange="page_summary('search')">
            <option value=""> --------------------</option>
            <logic:iterate id="subject" collection="<%= subjects %>">
            <%
              HashMap mapSubject = (HashMap) pageContext.getAttribute("subject");
              String subjectcode1 = (String) mapSubject.get("subjectcode");
              //String existSubjectcode = (String) pageContext.getAttribute("subjectcode");
              String strSelect = "";
              if ( subjectcode1.equals(subjectcode) )  strSelect = "Selected";
            %>
            <option value="<%=JspHelper.filterNull( subjectcode1 )%>" <%=JspHelper.filterNull( strSelect )%>>  <%=JspHelper.filterNull( (String) mapSubject.get("subjectname") )%></option>
            </logic:iterate>
          </select>
          <%--  <a href="javascript:page_summary('search')"><img src="../images/<%= strLanguageCode %>/go_fy.gif"border="0" style="border: 1 solid #000000"></a> --%>
        </td>
        <td></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
  <td>
    <table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
      <tr class="deepblue-left">
        <td class="title_center" width="22">&nbsp;</td>
        <td class="title_center" width="30"><a href="javascript:page_summary('orderby', 'sequence')"><%= label.getLabelName("L_Sequence") %></a></td>
        <td class="title_center"           ><%= label.getLabelName("L_DefaultTaskName") %></td>
        <td class="title_center"           ><%= label.getLabelName("L_DefaultTaskDesc") %></td>
        <td class="title_center" width="60"><%= label.getLabelName("L_DefaultPeriodNum") %></td>
        <td class="title_center" width="70"><%= label.getLabelName("L_IsDecisionMaker") %></td>
        <td class="title_center" width="60"><%= label.getLabelName("L_IsOptional") %></td>
        
        
        
        <td class="title_center" width="70"><%= label.getLabelName("L_ResponsibleEntity") %></td>
        
        <td class="title_center" width="70"><%= label.getLabelName("L_CustomeRespType") %></td>
        <td class="title_center" width="70"><%= label.getLabelName("L_FinalRespName") %></td>
        
        <td class="title_center" width="70"><%= label.getLabelName("L_Department") %></td>
        <td class="title_center" width="70"><%= label.getLabelName("L_TitleName") %></td>
        <td class="title_center" width="60"><%= label.getLabelName("L_UsrNeed") %></td>
      </tr>

    <% int j = 0;
       String strClassType = "";
       Integer nDefaultTaskId = new Integer(-1);
       //boolean bHasChecked = false;
       HashMap mapDefaultTask = new HashMap();
       String strTaskId = "";
        pageContext.setAttribute("displayflag","view");
    %>
    <logic:iterate id="defaultTask" collection="<%= defaultTaskSummary %>">
    <% mapDefaultTask = (HashMap) pageContext.getAttribute("defaultTask");
       strTaskId = ((Integer) mapDefaultTask.get("defaulttaskid")).toString();

       String strIsChecked = "";
       if ( j == 0 )
       {
       strIsChecked = "Checked";
       //bHasChecked = true;
       nDefaultTaskId = (Integer) mapDefaultTask.get("defaulttaskid");
       }

       if ( j % 2 == 1 )  strClassType = "td-listrom";
       else  strClassType = "";
       j++;
    %>
      <tr class="<%=JspHelper.filterNull( strClassType )%>" onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull( strClassType )%>'"  onClick="radioSelect('radiobox<%=JspHelper.filterNull( j )%>')">
        <td width="22">
          <input type="radio" id="radiobox<%=JspHelper.filterNull( j )%>" name="checkDefaultTask"  value=<%=JspHelper.filterNull( strTaskId )%>  class="checkbox" <%=JspHelper.filterNull( strIsChecked )%> onClick="javascript:clickRadio('<%=JspHelper.filterNull( strTaskId )%>')">
          <input type="hidden" name="taskid" value="<%=JspHelper.filterNull( strTaskId )%>">
        </td>
        <td width="30">&nbsp;
          <%=JspHelper.filterNull( mapDefaultTask.get("sequence") )%>
          <input type="hidden" name="sequence" value="<%=JspHelper.filterNull( mapDefaultTask.get("sequence") )%>">
        </td>
        <td>&nbsp;<%=JspHelper.filterNull( mapDefaultTask.get("defaulttaskname") )%></td>
        <td>&nbsp;<%=JspHelper.filterNull( mapDefaultTask.get("defaulttaskdesc") )%></td>
        <td width="60">&nbsp;<%=JspHelper.filterNull( mapDefaultTask.get("defaultperiodnum") )%><%=JspHelper.filterNull( mapDefaultTask.get("intervaltypename") )%></td>
        <%      Object obj = mapDefaultTask.get("isdecisionmaker");
        if ( obj != null ) {
        if ( ((String) obj).equalsIgnoreCase("Y") ) { %>
        <td width="70">&nbsp;<%= label.getLabelName("L_Yeah") %></td>
        <% } else { %>
        <td width="70">&nbsp;<%= label.getLabelName("L_Nott") %></td>
        <% }} %>
        
        <% obj = mapDefaultTask.get("isnecessary");
        if ( obj != null )
           {
        if ( ((String) obj).equalsIgnoreCase("Y") ) { %>
        <td width="60">&nbsp;<%= label.getLabelName("L_Yeah") %></td>
        <% } else { %>
        <td width="60">&nbsp;<%= label.getLabelName("L_Nott") %></td>
        <% }} %>
        
        
<% String Responsibilitytype = (String) mapDefaultTask.get("responsibilitytype");
        if ( Responsibilitytype.equalsIgnoreCase("U")) { %>
        <td width="70">&nbsp;<%=JspHelper.filterNull( mapDefaultTask.get("username") )%></td>
        <% } else if ( Responsibilitytype.equalsIgnoreCase("G")) { %>
        <td width="70">&nbsp;<%=JspHelper.filterNull( mapDefaultTask.get("usergroupname") )%></td>
        <% } else {%>
        <td width="70">&nbsp;</td>
        <% } %>
        <%
        if(!"Y".equals(mapDefaultTask.get("iscustomresponsible"))){%>
        <td width="70">&nbsp;</td>
        <td width="70">&nbsp;</td>
        <td width="70">&nbsp;</td>
        <td width="70">&nbsp;</td>
      <%}else{
        Integer oType=(Integer)mapDefaultTask.get("customtype");
        int iType=0;
        if(oType!=null)
          iType=oType.intValue();
          
       %>
        <td width="70"><custom:selectdic  name="defaultTask" property="customtype" dictType="CustomRestonibleType" displayType="view"/></td>
        <%if(iType==1){%>
        <td width="70"><custom:selectdic  name="defaultTask" property="jobtital" dictType="JobTitle" displayType="view"/></td>
      <%}else{%>
        <td width="70">&nbsp;</td>
        <%}
        if(iType==3){%>
        <td width="70"><custom:write  name="defaultTask" property="deptname" /></td>
        <td width="70"><custom:selectdic  name="defaultTask" property="jobtital" dictType="JobTitle" displayType="view"/></td>
      <%}else{%>
        <td width="70">&nbsp;</td>
        <td width="70">&nbsp;</td>
        <td width="70">&nbsp;</td>
        
        <%}%>
        <%}%>

        <% obj = mapDefaultTask.get("isusr");
        if ( obj != null )
           {
        if ( ((String) obj).equalsIgnoreCase("Y") ) { %>
        <td width="60">&nbsp;<%= label.getLabelName("L_Yeah") %></td>
        <% } else { %>
        <td width="60">&nbsp;<%= label.getLabelName("L_Nott") %></td>
        <% }} %>

      </tr>
    </logic:iterate>
 <%pageContext.removeAttribute("displayflag");%>
    <input type="hidden" name="defaulttaskid" value="<%=JspHelper.filterNull( nDefaultTaskId )%>">

    <%--  flipping page --%>
    <%@ include file="/inc/SummaryAction.inc" %>

    </table>
  </td>
</tr>
<tr>
  <td>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr><td class="summary_top" ></td></tr>
      <tr>
        <td class="td_center">
        <%--
          if (!"false".equals(pageContext.getAttribute("successflag"))){
        --%>
          <a onclick="page_new()"><custom:button type="1" label="L_New" imgsrc="new.gif" border="0" style="width:60"/></a>
        <%--}--%>
          <%if(defaultTaskSummary.size() != 0){%>
          <%--
            if (!"false".equals(pageContext.getAttribute("successflag"))){
          --%>
          <a onclick="page_edit()"><custom:button type="1" label="L_Edit" imgsrc="edit.gif" border="0" style="width:60"/></a>
          <a onclick="page_delete()"><custom:button type="1" label="L_Delete" imgsrc="delete.gif" border="0" style="width:60"/></a>
          <%--}--%>
          <a onclick="page_condition()"><custom:button type="1" label="L_Ifs" imgsrc="Condition.gif" border="0" style="width:60"/></a>
          <a onclick="page_advanced()"><custom:button type="1" label="L_AdvancedCond" imgsrc="AdvancedCond.gif" border="0" style="width:60"/></a>
          <%}%>
        </td>
      </tr>
    </table>
  </td>
</tr>
</table>
</form>
</body>
</html>


